package com.baby.movie.widget;

import com.baby.movie.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

public class MProgress extends LinearLayout {
	
	private ProgressBar mProgressBar;
	
	private TextView mTvMsg;

	public MProgress(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public MProgress(Context context) {
		super(context);
		init();
	}
	
	private void init() {
		LayoutInflater.from(getContext()).inflate(R.layout.layout_progress, this, true);
		mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
		mTvMsg = (TextView) findViewById(R.id.tvMsg);
	}
	
	public void show() {
		setVisibility(VISIBLE);
	}
	
	public void hide() {
		setVisibility(GONE);
	}
	
	public void showProgress() {
		show();
		mProgressBar.setVisibility(VISIBLE);
		mTvMsg.setVisibility(GONE);
	}
	
	public void setMessage(String msg) {
		show();
		mProgressBar.setVisibility(GONE);
		mTvMsg.setVisibility(VISIBLE);
		mTvMsg.setText(msg);
	}
	
	public void setTextClickListener(OnClickListener listener) {
		mTvMsg.setOnClickListener(listener);
	}
}
